package com.simple.datax.seda.util;

public class StringUtil {
	/**
	 * 切割字符串
	 * 
	 * @param source
	 *            源字符串
	 * @param split
	 *            切分字符
	 * @return 切分后的字符串数组
	 */
	public static String[] split(String source, String split) {
		String[] resultArray = null;
		if (source == null) {
			return null;
		}
		if (split == null) {
			resultArray = new String[1];
			resultArray[0] = source;
			return resultArray;
		}
		StringBuffer splitStr = new StringBuffer();
		for (int i = 0; i < split.length(); i++) {
			splitStr.append("[").append(split.charAt(i)).append("]");
		}
		if (source.endsWith(split)) {
			source = source + "iceberg";
			resultArray = source.split(splitStr.toString());
			resultArray[resultArray.length - 1] = "";
		} else {
			resultArray = source.split(splitStr.toString());
		}
		return resultArray;
	}
}
